#!/bin/bash

#################### 全局变量 #####################
# 属性文件目录
v_d_current=$(cd `dirname $0`; pwd)
export g_d_profile="/etc/profile.d/"
# 工具包
export g_d_util=${v_d_current}/util
# 读取属性文件工具
export g_f_util_properties=${g_d_util}/properties.sh
# 替换文件变量工具 ${name} -> zhangsan
export g_f_util_replace=${g_d_util}/replace.sh

#################### 执行脚本 #####################
if [ $# -eq 0 ]; then
    echo "Usage: $0 sh1[ sh2 ... shn]"
    exit -1
fi

# 检查文件是否存在
for arg in $@
do
    sh=${v_d_current}/${arg}/${arg}.sh
    if [ ! -f ${sh} ]; then
        echo "script file does not exist : $sh"
        exit -1
    fi
done

# 执行文件
for arg in $@
do
    sh=${v_d_current}/${arg}/${arg}.sh
    chmod +x ${sh}
    ${sh}
done